<div class="container">

    <div class="page-header">
        <div class="row">
            <h1 class="span8">Photo Gallery</h1>
            <span class="span4">

            </span>
        </div>

    </div>

    <div class="row">

        <div class="span8">

            <?php
                $this->load->view('parts/object_navigation');
            ?>

            <!--UPLOAD FORM -->
            <form accept-charset="utf-8" action="<?=base_url('object_gallery/submit_photos')?>" enctype="multipart/form-data" method="POST" id="uploadimage_form" name="uploadimage">  
                <div class="group">

                    <span class="group-title"> ADD PHOTOS &nbsp;&nbsp;

                    </span>          



                    <input type="hidden" value="new-pictures" name="post_action">
                    <input type="hidden" value="<?=$object_ID;?>" name="object_ID" id="object_ID">

                    <table class="form-table">
                        <tbody>
                            <tr valign="top">
                                <td class="upload_text">Upload image</td>
                                <td>
                                    <div id="plupload-upload-ui">
                                        <div>
                                            Choose files to upload                        
                                            <input type="button" class="button btn btn-mini" value="Select Files" id="plupload-browse-button" style="position: relative; z-index: 0;">
                                        </div>
                                        <div id="uploadQueue"></div>
                                    </div>
                                </td>
                            </tr> 
                        </tbody>
                    </table>





                    <div class="status_info"></div>        

                </div>

                <div class="form-actions">
                    <div class="row">
                        <span class="span2 save">
                            <a class="btn" id="plupload_btn">Upload images</a>
                        </span>
                    </div>

                </div>

            </form>

            <!--PICTURES FORM  -->
            <? if(count($pictures)>0 && isset($pictures[0]['filename'])):?>

                <form accept-charset="utf-8" action="<?=base_url('object_gallery/order_photos')?>" method="POST" name="orderPhotos">
                    <div class="group">

                        <span class="group-title"> Gallery &nbsp;&nbsp;

                        </span>



                        <input type="hidden" value="<?=$object_ID;?>" name="object_ID">
                        <table class="table table-striped table-bordered table-condensed">
                            <thead>
                                <tr>
                                    <th>Thumbnail</th>
                                    <th>Filename</th>
                                    <th class="center">Order</th>
                                </tr>
                            </thead>
                            <tbody>

                                <? $k=1; foreach($pictures as $picture): ?> 
                                    <? $folder = config_item('gallery_folder'); ?>
                                    <? $light_box = base_url().$folder.'/'.$picture['path'].'/thumb_454x340/'.$picture['filename']; ?>
                                    <? $thumbnail = base_url().$folder.'/'.$picture['path'].'/thumb_105x79/'.$picture['filename']; ?>

                                    <tr>

                                        <td class="column-thumbnail">
                                            <a rel="lightbox" title="<?=$picture['filename']?>" href="<?=$light_box?>">

                                                <img src="<?=$thumbnail?>" />

                                            </a>
                                        </td>
                                        <td>
                                            <div><strong><?=$picture['name']?></strong></div>

                                            <div><?=date('m.d.Y H:i',$picture['date_time'])?>h</div>
                                            <br>

                                            <div>

                                                <a onclick="javascript:check=confirm( 'Delete &quot;<?=$picture['name']?>&quot; ?');if(check==false) return false;" href="<?=base_url('object_gallery/delete_picture/'.$picture['ID'].'/'.$object_ID)?>">Delete</a>

                                            </div>

                                        </td>
                                        <td class="column-order">

                                            <input name="picture-order[]" value="<?=$picture['order']?>" tabindex="<?=$k+5?>" />

                                        </td>

                                    </tr>


                                    <? $k++; endforeach; ?>
                            </tbody>
                        </table>


                    </div>

                    <div class="form-actions">
                        <div class="row">
                            <span class="span2 save">
                                <button type="submit" class="btn btn-primary">Save changes</button>
                            </span>
                        </div>

                    </div>
                </form>

                <?endif;?>

            <script type="text/javascript">
                var pro_gallery = '<?=config_item('gallery_folder')?>';
                var object_gallery_folder = '<?=$object_gallery_folder?>';
            </script>

        </div>

    </div>

</div>